// pages/movie/movie.js
const http2 = require("../../models/http2.js");
const {handleTitle,transfromStar} = require("../../utils/index.js");-
Page({
  data: {
    movies:[],
    rating:"",
    arr:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

      http2({
        success: (result)=>{
          /* console.log(result.data.result);
          this.setData({
            movies:result.data.result
          }) */
          this.handleHttpData(result.data.result)
        }
      })
      var data = this.data.raiting;
      console.log(data);
      var stars = this.transfromStar(data);
      this.setData({
        arr:stars
      })
      this.show()
  },
  show(){
    console.log(show);
  },
  handleHttpData(res){
        // console.log(res);
        res.forEach(item=>{
          // console.log(item);
          // item["title"]= this.handTitle(item["title"])
          item["title"]= handleTitle(item["title"])
          item["rate"]= transfromStar(item["raiting"])
        })
        console.log(res);
        this.setData({
          movies:res
        })
  },

  handleToggle(event){
    let {id} = event.currentTarget.dataset;
    wx.navigateTo({
      // url: '/pages/detail/detail',
      url: `/pages/movie-detail/movie-detail?id=${id}`,
      
    });
  }
})